import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) throws Exception {
        String date="a我b";
        //默认UTF-8编码
        byte[] bytes=date.getBytes();
        System.out.println(Arrays.toString(bytes));
        //指定GBK编码
        byte[] bytes1=date.getBytes("GBK");
        System.out.println(Arrays.toString(bytes1));
        //默认UTF-8解码
        String s1=new String(bytes);
        System.out.println(s1);
        //指定GBK解码
        String s2=new String(bytes,"GBK");
        System.out.println(s1);
    }
}
